﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace V5_EShop {
    public class BasicPage : System.Web.UI.Page {
        public bool Debug = ConfigurationManager.AppSettings["Debug"].ToUpper() == "TRUE" ? true : false;
        protected string Action = string.Empty;
        protected override void OnError(EventArgs e) {
            HttpContext ctx = HttpContext.Current;
            Exception exception = ctx.Server.GetLastError();
            string errorInfo = string.Empty;
            if (Debug) {
                errorInfo = "<br>Offending URL: " + ctx.Request.Url.ToString() +
                 "<br>Source: " + exception.Source +
                 "<br>Message: " + exception.Message
                 + "<br>Stack trace: " + exception.StackTrace;
            }
            else {
                errorInfo = "<br>Source: " + exception.Source +
                 "<br>Message: " + exception.Message;
            }
            ctx.Response.Write(errorInfo);
            ctx.Server.ClearError();
            base.OnError(e);

        }
    }
}